import React from "react";
import { useEffect, useState } from "react";
const App = () => {
  /* 定义多个useEffect,关注点分离 */
  let [count, setCount] = useState(2);
  useEffect(() => {
    console.log(1); // 打印1
  }, [count]);
  useEffect(() => {
    console.log(2); // 打印2
    console.log("发请求拿数据");
  }, []);
  return (
    <div>
      <h1>count</h1>
      <button
        onClick={() => {
          setCount(count + 1);
        }}
      >
        +1
      </button>
    </div>
  );
};

export default App;
